﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using ConfOrm;
using ConfOrm.NH;
using ConfOrm.Patterns;
using ConfOrm.Shop.CoolNaming;
using Eg.Core;
using NHibernate;
using NHibernate.Cfg.MappingSchema;

namespace Eg.ConfORMMappings
{
    class Program
    {
        static void Main(string[] args)
        {
        }

        private static void GetMapping()
        {
            var orm = new ObjectRelationalMapper();
            var mapper = new Mapper(orm, new CoolPatternsAppliersHolder(orm));

            orm.TablePerClassHierarchy<Product>();
            orm.TablePerClass<ActorRole>();

            orm.Patterns.PoidStrategies.Add(new GuidOptimizedPoidPattern());
            orm.VersionProperty<Entity>(e => e.Version);
            orm.NaturalId<Product>(p => p.Name);

            orm.Cascade<Movie, ActorRole>(Cascade.All | Cascade.DeleteOrphans);

            mapper.AddPropertyPattern(
                mi => mi.GetPropertyOrFieldType() == typeof(decimal) &&
                    mi.Name.Contains("Price"),
                    pm => pm.Type(NHibernateUtil.Currency));
            
        }
    }
}
